﻿#include "setplansform.h"
#include "ui_setplansform.h"

#include <QGraphicsDropShadowEffect>

SetPlansForm::SetPlansForm(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::SetPlansForm)
{
    ui->setupUi(this);

    plansForm = new PlansForm();
    woodTypeForm = new WoodTypeForm();
    defectForm = new DefectForm();

    ui->gridLayout->addWidget(plansForm,1,0);
    ui->gridLayout->addWidget(defectForm,1,0);
    ui->gridLayout->addWidget(woodTypeForm,1,0);
    ui->gridLayout->setSpacing(0);
    plansForm->hide();
    defectForm->hide();
    woodTypeForm->hide();


    qDlg = plansForm;
    SwitchFrom(0);


    //内层窗口添加对应的阴影效果
    QGraphicsDropShadowEffect *shadow_effect = new QGraphicsDropShadowEffect(this);
    shadow_effect->setOffset(0, 0);
    shadow_effect->setColor(QColor(150,150,150));
    shadow_effect->setBlurRadius(6);
    ui->widget_title->setGraphicsEffect(shadow_effect);
}

SetPlansForm::~SetPlansForm()
{
    delete ui;
}

void SetPlansForm::SwitchFrom(int index)
{

    qDlg->hide();
    switch (index) {
    case 0:
        qDlg = plansForm;
        break;
    case 1:
        qDlg = defectForm;
        defectForm->UpdateTable();
        break;
    case 2:
        qDlg = woodTypeForm;
        break;
    case 3:
        // qDlg = configC;
        break;
    }
    qDlg->show();
}

void SetPlansForm::on_Bt_set_plan_clicked()
{
    SwitchFrom(0);
}

void SetPlansForm::on_Bt_set_defect_clicked()
{
    SwitchFrom(1);
}

void SetPlansForm::on_Bt_set_wood_clicked()
{
    SwitchFrom(2);
}


